In [1]:
run ../../common.ipynb
In [2]:
# import filters from scikit-image
from skimage import filter
In [3]:
image = imread('../mp.tif')
optimal_threshold = filter.threshold_otsu(image)
In [4]:
mask = image < optimal_threshold
gimshow(mask);
Show only regions above threshold
In [5]:
image[image<optimal_threshold] = 0
imsave('mp_otsu_above.png', 255-image) #invert image also
from IPython.display import Image
Image('mp_otsu_above.png') # inlucde whole image in notebook
Out[5]:
Now with laplace -> then otsu
In [6]:
image = imread('../mp.tif')
laplace = ndimage.laplace(image)
optimal_threshold_laplace = filter.threshold_otsu(laplace)
image[image < optimal_threshold_laplace] = 0
imsave('mp_otsu_laplace_above.png', 255-image) #invert image
Image('mp_otsu_laplace_above.png')
Out[6]: